<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>批量发货</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div id="app">
    <div class="content-header">
        <h1>管理<small>order管理</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>管理</el-breadcrumb-item>
            <el-breadcrumb-item>order管理</el-breadcrumb-item>
            <el-breadcrumb-item>批量发货</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <div class="filter-container">
                    <el-form :inline="true" >
                        <el-button type="info" class="butT" onclick="location.href='order.html'">返回</el-button>
                    </el-form>
                </div>

                <el-table
                        ref="multipleTable"
                        :data="tableData"
                        tooltip-effect="dark"
                        style="width: 100%"
                        @selection-change="handleSelectionChange">
                    <el-table-column prop="id" label="订单编号" width="200"></el-table-column>
                    <el-table-column prop="receiverContact" label="收件人" width="150"></el-table-column>
                    <el-table-column prop="receiverMobile" label="手机号码" width="150"></el-table-column>
                    <el-table-column prop="receiverAddress" label="收货地址" width="150"></el-table-column>
                    <el-table-column prop="sourceType" label="配送方式" width="150">
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.shippingName" placeholder="请选择">
                                <el-option
                                        v-for="item in options"
                                        :key="item"
                                        :label="item"
                                        :value="item">
                                </el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column prop="orderStatus" label="物流单号" width="150">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.shippingCode" placeholder="请输入物流单号"></el-input>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="margin-top: 20px">
                    <el-button style="margin-left: 500px;margin-top: 5px" @click="toggleSelection()">取消</el-button>
                    <el-button style="margin-left: 50px" @click="toggleSelection(tableData)">保存</el-button>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script src="/js/elementui.js"></script>
<script src="/js/util.js"></script>
<script>
    new Vue({
        el: '#app',
        data(){
            return {
                tableData:[],
                ids:[],
                // searchMap:{,consign:0},//searchMap:{"ids":["1132112186555109376","1132295753927102464"]}
                options:["顺风快递","韵达快递","天天快递","圆通快递"],
                multipleSelection: []
            }
        },
        created(){
            this.ids = JSON.parse(getQueryString("idss"));
            this.fetchData();
        },
        methods:{
            fetchData(){
                axios.post(`/order/findNotSendOrderList.do`,this.ids).then(response=>{
                    this.tableData=response.data;
                });
            },
            sub(){
                axios.post(`/order/batchSend.do`,this.multipleSelection).then(response=>{
                    if(response.data.code==0){
                    this.fetchData();//刷新列表
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
                        duration: 900 //持续时间
                        })
                    }else{
                        this.$alert('操作失败','错误提示');
                    }
                });
            },
            toggleSelection(rows) {
                if (rows) {
                    rows.forEach(row => {
                        this.$refs.multipleTable.toggleRowSelection(row);
                    });
                } else {
                    this.$refs.multipleTable.clearSelection();
                }
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;//获取复选框集合 val代表整个表格里对象的集合
                this.sub();
            }
        }
    })
</script>
</html>